import adaptee.EuropeanPowerSource;
import adapter.PowerAdapter;
import adapter.PowerClassAdapter;
import client.USAppliance;
import targetClass.USPowerSource;

public class AdapterDemo {

    public static void main(String[] args) {
        // 在欧洲使用美国电器(对象适配器)
        EuropeanPowerSource europeanPower = new EuropeanPowerSource();
        USPowerSource adapter = new PowerAdapter(europeanPower); // 使用对象适配器

        USAppliance appliance = new USAppliance(adapter);
        appliance.operate();

        // 在欧洲使用美国电器(类适配器)
        USPowerSource adapterClass = new PowerClassAdapter();
        USAppliance applianceClass = new USAppliance(adapterClass);
        applianceClass.operate();
    }
}
